package com.mocchira.music.radio.web;

public class StringUtil {
    public static String escapeRegexStr(String src) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < src.length(); i++) {
            char c = src.charAt(i);
            String rep = "";
            switch (c) {
            case '\\':
                rep = "\\\\";
                break;
            case '*':
                rep = "\\*";
                break;
            case '+':
                rep = "\\+";
                break;
            case '.':
                rep = "\\.";
                break;
            case '?':
                rep = "\\?";
                break;
            case '{':
                rep = "\\{";
                break;
            case '}':
                rep = "\\}";
                break;
            case '(':
                rep = "\\(";
                break;
            case ')':
                rep = "\\)";
                break;
            case '[':
                rep = "\\[";
                break;
            case ']':
                rep = "\\]";
                break;
            case '^':
                rep = "\\^";
                break;
            case '$':
                rep = "\\$";
                break;
            case '-':
                rep = "\\-";
                break;
            case '|':
                rep = "\\|";
                break;
            default:
                rep = Character.toString(c);
                break;
            }
            builder.append(rep);
        }
        return builder.toString();
    }
}
